package m.jclecai.com.adapter;

import android.content.Context;
import android.view.ViewGroup;

import m.jclecai.com.R;

import m.jclecai.com.adapter.base.ViewHolerAdapter;
import m.jclecai.com.adapter.holder.BetJclqHolder;
import m.jclecai.com.bean.ZqItem;
import m.jclecai.com.listener.MyNotifyTextViewSetChanged;
import m.jclecai.com.utils.Utils;

/**
 * Created by ZD on 2017/5/6.
 */

public class BetJclqAdapter extends ViewHolerAdapter<BetJclqHolder> {

    private Context mContext;
    int pager = 0;
    MyNotifyTextViewSetChanged change;

    public BetJclqAdapter(Context context, int pager, MyNotifyTextViewSetChanged change) {
        this.mContext = context;
        this.pager = pager;
        this.change = change;
    }

    @Override
    public BetJclqHolder onCreateViewHolder(int position, ViewGroup parent) {
        return new BetJclqHolder(mContext, R.layout.item_jclq);
    }

    @Override
    public void onBindViewHolder(final int position,final BetJclqHolder betJczqHolder) {
        final ZqItem zqItem = Utils.ZQ_ITEM_LIST.get(position);
        betJczqHolder.init(zqItem,pager,position);
//        betJczqHolder.isShowSplit(position < getCount()-1);
        betJczqHolder.setChangeListener(change);
    }

    @Override
    public int getCount() {
        return Utils.ZQ_ITEM_LIST.size();
    }

    public int getCheckDan() {
        int checkCount = 0;
        for (int i=0;i<Utils.ZQ_ITEM_LIST.size();i++){
            if(Utils.ZQ_ITEM_LIST.get(i).isDan_select())
                checkCount++;
        }
        return checkCount;
    }
}
